﻿
CREATE PROCEDURE [dbo].[proc_Order_Change_ProjectItem_Hedge]
	(
		@CId int,
		@PId uniqueidentifier,
		@CreateUser varchar(30)
	)
AS
Begin
	Update [Order_Change] Set flag=1 Where Id=@CId And flag=0
	Insert Into Order_Change_Project(CId,OId,ProductId,ProductName
,SupplierId,SupplierName,CostPrice,SalePrice,Description,TypeId
,TypeName,IsFinish,CompanyId,Salesman,SalesmanAccount,CreateUser,FinishDate
,ExecDepartmentId,ExecPerson
,FinanceAudit,SCateOneId,SCateTwoId,SubjectId,UpTime,Project_Id)
	Select @CId,
      OrderId
      ,ProductId
      ,ProductName
      ,SupplierId
      ,SupplierName
      ,0-CostPrice
      ,0-SalePrice
      ,'项目「'+ProductName+'」的对冲数据'
      ,TypeId
      ,TypeName
      ,1
      ,CompanyId
      ,Salesman
      ,SalesmanAccount
      ,@CreateUser
      ,GetDate()
,ExecDepartmentId,ExecPerson
      ,1
      ,SCateOneId
      ,SCateTwoId
      ,SubjectId
      ,GetDate(),Id
	From Project Where ProjectId=@PId
End